package com.ykdl.member.kid.beans;

import java.io.Serializable;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import net.wxxr.http.interfaces.IJsonParser;

public class HomeMessageCount implements Serializable, IJsonParser {
	private static final long serialVersionUID = 8980459518508393899L;
	
	private int unread_count ;
	private int new_messages_count = 0;
	private int notification_count = 0;
	
	public int getNew_messages_count() {
		return new_messages_count;
	}

	public int getNotification_count() {
		return notification_count;
	}

	public int getUnread_count() {
		return unread_count;
	}

	private boolean isExpired = false;
	

	public boolean isExpired() {
		return isExpired;
	}

	public void setExpired(boolean isExpired) {
		this.isExpired = isExpired;
	}
	
	@Override
	public IJsonParser parse(String json) throws Exception {
		Gson  gson = null;
		HomeMessageCount  bean = null;
		if(null != json){
			GsonBuilder b = new GsonBuilder();
			gson  = b.create();
			bean = new HomeMessageCount();
			if(json.startsWith("{") && json.endsWith("}")
					&& new JSONObject(json).has("error")
					&& new JSONObject(json).getInt("error") == 20007){
				bean.setExpired(true);
				return bean;
			}
			bean = gson.fromJson(json, HomeMessageCount.class);
		}
		return bean;
	}

}
